package com.monika.main.system.mq;

import com.lmax.disruptor.EventHandler;
import com.lmax.disruptor.WorkHandler;

/**
 * @author:whh
 * @date: 2024-12-04 22:28
 * <p>
 *
 *
 * </p>
 */
public class MsgEventHandler implements EventHandler<MsgEvent>, WorkHandler<MsgEvent> {

    private String name;

    public MsgEventHandler(String name) {
        this.name = name;
    }


    @Override
    public void onEvent(MsgEvent event, long sequence, boolean endOfBatch) throws Exception {
        System.out.println(name+"-----start-----"+sequence);
        Thread.sleep(1000*10);
        System.out.println("ThreadName:  "+Thread.currentThread().getName());
        System.out.println(event.getData()+" end seq: "+sequence);
    }

    @Override
    public void onEvent(MsgEvent event) throws Exception {
        System.out.println(name+"-----start-----");
        Thread.sleep(1000*10);
        System.out.println("ThreadName:  "+Thread.currentThread().getName());
        System.out.println(event.getData());
        System.out.println(name+"-----end-----");


    }
}
